{% extends 'TopxiaWebBundle:My:layout.html.twig' %}

{% block title %}{{'在教课程'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'my-teaching-courses' %}

{% set type="question" %}

{% block main %}

<div class="panel panel-default panel-col lesson-manage-panel">
  <div class="panel-heading">
    <span class="pull-right">
      <a id="create-course" href="{{ path('course_create') }}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-plus"></span> {{'创建课程'|trans}}</a>
    </span>
    {{'在教课程'|trans}}
  </div>

  <div class="panel-body">
    {% include 'TopxiaWebBundle:MyTeaching:course-tab.html.twig'%}

    <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
      <thead>
      <tr>
        <th width="50%">{{'名称'|trans}}</th>
        <th>{{'浏览数'|trans}}</th>
        <th>{{'状态'|trans}}</th>
        <th width="20%">{{'操作'|trans}}</th>
      </tr>
      </thead>
      <tbody>
      {% if courses %}
       	{% for course in courses %}
       	 <tr>
            <td>
              <a class="pull-left mrm" href="{{ path('open_course_show', {courseId:course.id}) }}" title="{{ course.title }}">
                <img class="course-picture" src="{{ filepath(course.middlePicture, 'course.png') }}" alt="{{ course.title }}" width="100">
              </a>

              <div class="mlm">
                <a href="{{ path('open_course_show', {courseId:course.id}) }}" title="{{ course.title }}">{{ course.title }}</a>
                {% if course.type == 'liveOpen' %}
                  <span class="label label-success live-label">{{'直播'|trans}}</span>
                {% endif  %}
              </div>
            </td>
            <td>{{ course.hitNum }}</td>
            <td>{{ dict_text('courseStatus:html', course.status) }}</td>
            <td>
              <div class="btn-group">
                {% if 'ROLE_SUPER_ADMIN' in app.user.roles %}
                  <a class="btn btn-default btn-sm" href="{{ path('open_course_manage', {id:course.id}) }}">{{'管理'|trans}}</a>
                {% elseif 'ROLE_TEACHER' in app.user.roles %}
                  <a class="btn btn-default btn-sm" href="{{ path('open_course_manage', {id:course.id}) }}">{{'查看'|trans}}</a>
                {% endif %}

                <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                  <span class="caret"></span>
                </a>
                <ul class="dropdown-menu pull-right">
                  {% if course.type != 'liveOpen' %}
                    <li><a href="{{ path('open_course_manage_lesson', {id:course.id}) }}">{{'课时管理'|trans}}</a></li>
                    <li><a href="{{ path('open_course_manage_files', {id:course.id}) }}">{{'文件管理'|trans}}</a></li>
                  {% endif %}
                  <li><a href="{{ path('open_course_manage_students', {id:course.id}) }}">{% if setting('default.user_name') %}{{setting('default.user_name')|default('学员'|trans)}}{% else %}{{'学员'|trans}}{% endif %}{{'管理'|trans}}</a></li>
                </ul>
              </div>
            </td>
          </tr>
        {% endfor %}
        {% else %}
          <tr><td colspan="20"><div class="empty">{{'暂无在教的公开课'|trans}}</div></td></tr>
       {% endif %}
        
      </tbody>
    </table>
    <nav class="text-center">
      {{ web_macro.paginator(paginator) }}
    </nav>
  </div>
</div>

{% endblock %}